{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "- 需求：提取每只可转债的每年利息，并返回一个dataframe表格，每年利息为1列。\n",
    "  - col: 转债名称，代码，第一年利息，.... ,第n年利息\n",
    "- data： `raw-data/cbond-interest-info.xlsx`\n",
    "- 文件命名方式：姓名-学号-re-exercise.ipynb\n",
    "  - 如： 贾东晓-19XXXX-re-exercise.ipynb\n",
    "- 在gitee中使用pull request提交至 HW/HW-submit 文件夹\n",
    "  - 注意相对路径使用是以HW-submit文件夹为起点，建议建立分支同步课程仓库，在HW-submit文件夹中复制作业文件并修改。\n",
    "- 截止时间：2022年4月26日晚10点前"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "import os\n",
    "import re\n",
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "os.chdir('../lecture-python/raw-data')  \n",
    "#注意：若在HW-submit中，需要修改路径"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['baby_trade_history.csv',\n",
       " 'bond_intraday_trade.csv',\n",
       " 'cbond-interest-info.xlsx',\n",
       " 'cfps2018_famconf_demo.csv',\n",
       " 'meal_order_detail.xlsx',\n",
       " 'sam_tianchi_mum_baby.csv',\n",
       " 'titanic.csv',\n",
       " 'titanic.xlsx']"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "os.listdir()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [],
   "source": [
    "cbond = pd.read_excel('cbond-interest-info.xlsx')\n",
    "cbond.columns = ['code','name','interest-info']\n",
    "cbond.drop(index=[0],inplace = True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>code</th>\n",
       "      <th>name</th>\n",
       "      <th>interest-info</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>110043.SH</td>\n",
       "      <td>无锡转债</td>\n",
       "      <td>第一年0.30%、第二年0.50%、第三年0.80%、第四年1.00%、第五年1.30%、第...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>110044.SH</td>\n",
       "      <td>广电转债</td>\n",
       "      <td>本次发行的可转债票面利率：第一年0.40%、第二年0.60%、第三年1.00%、第四年1.5...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>110045.SH</td>\n",
       "      <td>海澜转债</td>\n",
       "      <td>第一年为0.3%、第二年为0.5%、第三年为0.8%、第四年为1.0%、第五年为1.3%、第...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>110046.SH</td>\n",
       "      <td>山鹰转债</td>\n",
       "      <td>第一年0.5%、第二年0.8%、第三年1.0%、第四年1.5%、第五年1.8%、第六年2.0%。</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>110047.SH</td>\n",
       "      <td>福能转债</td>\n",
       "      <td>第一年0.4%、第二年0.6%、第三年1.0%、第四年1.5%、第五年2.0%、第六年3.0%</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "        code  name                                      interest-info\n",
       "1  110043.SH  无锡转债  第一年0.30%、第二年0.50%、第三年0.80%、第四年1.00%、第五年1.30%、第...\n",
       "2  110044.SH  广电转债  本次发行的可转债票面利率：第一年0.40%、第二年0.60%、第三年1.00%、第四年1.5...\n",
       "3  110045.SH  海澜转债  第一年为0.3%、第二年为0.5%、第三年为0.8%、第四年为1.0%、第五年为1.3%、第...\n",
       "4  110046.SH  山鹰转债   第一年0.5%、第二年0.8%、第三年1.0%、第四年1.5%、第五年1.8%、第六年2.0%。\n",
       "5  110047.SH  福能转债    第一年0.4%、第二年0.6%、第三年1.0%、第四年1.5%、第五年2.0%、第六年3.0%"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cbond.head()"
   ]
  }
 ],
 "metadata": {
  "interpreter": {
   "hash": "b3ba2566441a7c06988d0923437866b63cedc61552a5af99d1f4fb67d367b25f"
  },
  "kernelspec": {
   "display_name": "Python 3.9.7 ('base')",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.7"
  },
  "orig_nbformat": 4
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
